package com.wanshi.config;

import javax.servlet.ServletContext;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {

    private static Properties prop = new Properties();

    static{
        String path = AlipayConfig.class.getClassLoader().getResource("jingdong.properties").getPath();
        try {
            prop.load(new FileReader(path));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
	
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "2021000117682955";
	
	// 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDLZdy5tX7s8u3coGptuC/926vS0wPDnKvokpWC94/aDcXT8fNXf/OBLF+QvvID9zxQH6njmXFxPkmtoeazkX0/Uzb3ZSVPmRPyvIRYF1n0hbfXZpd+qYCVar5xvfxsuGFN7oJPSZQM0jVeOwF3GNlwyseuWu1B1BAtH0cvI9ldup30VYh3171CnbwzI4Euq5XGj0fNcFcg9kqHf1bIMQBFpjzev8q8EHDw+10BGzcwy8dU6A/QyqDy9w1rlMHX8Ig/agFjz+DUXuFeFmkIqxa9JMUwE5vidR4F/mj42x4NZGXCG1CHNtTdatkkRbKVgVpg5p9UDDDecIyb06CRyjTTAgMBAAECggEBAIhcbSNv4301zHQqc8/FOR+HQ2WfJJnjEnlktKnOEPoOW7+hKRRTaswCFLu02AoCmcPZxosZFy3lpX2r2kAu3Po0bthjTiVUKkSFUHDCjwNZFoxpck1vlA4YNz+IMJAu+MVHjsNbP89sqmzXQD85Q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wmWwik/qhw=";
	
	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm+1Ho+hSrLsydTWb1iPrcJ6YB5lNtJGkId3YXDV3CjjxZ35VBygN2X+pcf6A2dp+Ag9dBQCvWkqu12We2yhmhH+EYujrdjHh6lSf3OQxK0v7LUTWFTnP9UbpTLEwnsjTXZkYwwMph051wmdl6yMhwY4gkb3hts2ePu9R6NIyp9k0aWFwdmVwGsf/txsmUrg3A6uIvLNSr9GG0Uc5CUbGX0z6+dABXx9FgCFDRI147OiI/gu+WrzL7/EB5YC3136YJ2K+T7AQWfcUPK40y2l6mORmiLytXqlwRtIxEvYo/ggxXVuJ8kmjgvTapQh0yltN5BCDBpsj7fxI0J/Chai85wIDAQAB";

	// 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	//public static String notify_url = "http://49.233.201.117:8080/jingdong/notify";
	public static String notify_url =  prop.getProperty("notify_url");

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	//public static String return_url = "http://49.233.201.117:8080/jingdong/index.jsp";
	public static String return_url = prop.getProperty("return_url");

	// 签名方式
	public static String sign_type = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	// 支付宝网关
	//public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";
	public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

	// 支付宝网关
	public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /** 
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

